/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sdd.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;

/**
 *
 * @author Carlos
 */
@Entity
public class Comment implements Serializable {

    private static final long serialVersionUID = 1L;
    private Long id;
    private String text;
    private Customer commentator;
    private Product product;
    private Date dateAdded;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Comment)) {
            return false;
        }
        Comment other = (Comment) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.sdd.entities.Comment[ id=" + id + " ]";
    }

    /**
     * @return the text
     */
    public String getText() {
        return text;
    }

    /**
     * @param text the text to set
     */
    public void setText(String text) {
        this.text = text;
    }

    /**
     * @return the commentator
     */
    @ManyToOne
    public Customer getCommentator() {
        return commentator;
    }

    /**
     * @param commentator the commentator to set
     */
    public void setCommentator(Customer commentator) {
        this.commentator = commentator;
    }

    /**
     * @return the product
     */
    @ManyToOne
    public Product getProduct() {
        return product;
    }

    /**
     * @param product the product to set
     */
    public void setProduct(Product product) {
        this.product = product;
    }

    /**
     * @return the dateAdded
     */
    @Temporal(javax.persistence.TemporalType.DATE)
    public Date getDateAdded() {
        
        return dateAdded;
    }

    /**
     * @param dateAdded the dateAdded to set
     */
    public void setDateAdded(Date dateAdded) {
        this.dateAdded = dateAdded;
    }
}
